home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / RINSTR.DMO < prev    next >
Text File  |  1996-07-04  |  2KB  |  50 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   RINSTR  .DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NB01.INC"
  22. COLOR 7, 0
  23. CLS
  24.  
  25. ? "┌─────────────────────────────────────────────────────────────────
  26. ? "│ fRINSTR%( Start%, ANY, Search$ )
  27. ? "├───────────────────────────────────────────────────────────────────
  28. ? "│ Reverse INSTR searches for the first occurrence of Search$ in ANY$
  29. ? "│ starting at the Start%th character and returns the MID$ position
  30. ? "│ of Search$ or ZERO if it is not found.
  31. ? "└───────────────────────────────────────────────────────────────────────
  32.  
  33. MAP A$$ * 30
  34. A$$ = "THIS IS A RATHER LONG TEST 123"
  35. S$  = "TH"
  36. D$ = "Search for each occurrence of `"+ S$ + "` in `" + A$$ + "`"
  37.  
  38. REPLACE "`" WITH CHR$(34) IN D$
  39. PRINT
  40. PRINT D$
  41. PRINT
  42. DO
  43.   P% = fRINSTR% ( P%, A$$, S$ )                         ' if P% = 0 then
  44.   IF P% > 0 THEN                                        ' fRINSTR will start
  45.     PRINT USING$( "MIDpos: ## ", P%); MID$( A$$, P% )   ' at the end of A$$
  46.     DECR P%, 1                                          ' so you don't have
  47.   END IF                                                ' to compute LEN(A$$)
  48.   IF INSTAT THEN EXIT LOOP                              '
  49. LOOP UNTIL P% = 0
  50.